package andriod.action.template;

import java.io.PrintWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;

import net.sf.json.JSONArray;

import com.jcrj.action.BaseAction;
import com.jcrj.entity.TemplateFile;
import com.jcrj.service.TemplateService;

public class TemplateAction extends BaseAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = -1474088374003020180L;
	private TemplateService templateService;

	public TemplateService getTemplateService() {
		return templateService;
	}

	public void setTemplateService(TemplateService templateService) {
		this.templateService = templateService;
	}

	public String templateContentList() {
		try {
			List<TemplateFile> list = this.templateService.findTemplateList();
			JSONArray array = JSONArray.fromObject(list);
			
			getResponse().setContentType("text/json;charset=utf-8");
			PrintWriter writer = getResponse().getWriter();
			writer.print(array.toString());
			writer.flush();
			writer.close();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
